home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / TIMING.SWG / 0027_World Clock Program.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  11KB  |  518 lines

  1. uses dos,crt,cfont,graph;
  2.  
  3. const
  4.      no = 16;
  5.  
  6. type
  7.     info = record
  8.         name   : string;
  9.         secs   : integer;
  10.         mins   : integer;
  11.         hours  : integer;
  12.     end;
  13.  
  14. var
  15.    lastno : integer;
  16.    loop   : integer;
  17.    loop2  : integer;
  18.    data   : array[1..no] of info;
  19.    gm,gd  : integer;
  20.    co     : integer;
  21.  
  22. function lz(w : integer) : String;
  23. var
  24.   s : String;
  25. begin
  26.   Str(w:0,s);
  27.   if Length(s) = 1 then
  28.     s := '0' + s;
  29.   lz := s;
  30. end;
  31.  
  32. procedure precalc;
  33.  
  34. var
  35.    x : integer;
  36.  
  37. begin
  38.      x := 0;
  39.      for loop := 1 to no do
  40.      begin
  41.           if data[loop].hours > 23 then
  42.           begin
  43.                x := data[loop].hours - 24;
  44.                data[loop].hours := x;
  45.           end;
  46.           if data[loop].mins > 59 then
  47.           begin
  48.                x := data[loop].mins - 59;
  49.                data[loop].mins := x;
  50.           end;
  51.           if data[loop].secs > 59 then
  52.           begin
  53.                x := data[loop].secs - 59;
  54.                data[loop].secs := x;
  55.           end;
  56.      end;
  57. end;
  58.  
  59. procedure presetclock;
  60.  
  61. var
  62.    h,m,s,hund : word;
  63.    loop       : integer;
  64.  
  65. begin
  66.      GetTime(h,m,s,hund);
  67.      for loop := 1 to no do
  68.      begin
  69.           data[loop].hours := data[loop].hours + h;
  70.           data[loop].mins := data[loop].mins + m;
  71.           data[loop].secs := data[loop].secs + s;
  72.      end;
  73. end;
  74.  
  75. procedure showtime;
  76.  
  77. begin
  78.      delay(710);
  79.      for loop := 1 to no do
  80.      begin
  81.           inc(data[loop].secs);
  82.           if data[loop].secs > 59 then
  83.           begin
  84.                inc(data[loop].mins);
  85.                data[loop].secs := 0;
  86.                if data[loop].mins > 59 then
  87.                begin
  88.                     data[loop].mins := 0;
  89.                     inc(data[loop].hours);
  90.                     if data[loop].hours > 23 then
  91.                      begin
  92.                           data[loop].hours := 0;
  93.                      end;
  94.                end;
  95.          end;
  96.     end;
  97. end;
  98.  
  99. begin
  100.      gd := detect;
  101.      initgraph(gd,gm,'\turbo\tp');  { change this !! }
  102.      data[1].name := 'LONDON';
  103.      data[1].secs := 0;
  104.      data[1].mins := 0;
  105.      data[1].hours := 0;
  106.      data[2].name := 'PARIS';
  107.      data[2].secs := 0;
  108.      data[2].mins := 0;
  109.      data[2].hours := 1;
  110.      data[3].name := 'ATHINS';
  111.      data[3].secs := 0;
  112.      data[3].mins := 0;
  113.      data[3].hours := 2;
  114.      data[4].name := 'PEKING';
  115.      data[4].secs := 0;
  116.      data[4].mins := 0;
  117.      data[4].hours := 8;
  118.      data[5].name := 'TOKYO';
  119.      data[5].secs := 0;
  120.      data[5].mins := 0;
  121.      data[5].hours := 9;
  122.      data[6].name := 'SYDNEY';
  123.      data[6].secs := 0;
  124.      data[6].mins := 0;
  125.      data[6].hours := 10;
  126.      data[7].name := 'NEW YORK';
  127.      data[7].secs := 0;
  128.      data[7].mins := 0;
  129.      data[7].hours := -5;
  130.      data[8].name := 'MOSCOW';
  131.      data[8].secs := 0;
  132.      data[8].mins := 0;
  133.      data[8].hours := 3;
  134.      data[9].name := 'RIO';
  135.      data[9].secs := 0;
  136.      data[9].mins := 0;
  137.      data[9].hours := -3;
  138.      data[10].name := 'LOS ANGELES';
  139.      data[10].secs := 0;
  140.      data[10].mins := 0;
  141.      data[10].hours := -8;
  142.      data[11].name := 'HONOLULU';
  143.      data[11].secs := 0;
  144.      data[11].mins := 0;
  145.      data[11].hours := -10;
  146.      data[12].name := 'HONG KONG';
  147.      data[12].secs := 0;
  148.      data[12].mins := 0;
  149.      data[12].hours := 8;
  150.      data[13].name := 'SINGAPORE';
  151.      data[13].secs := 0;
  152.      data[13].mins := 0;
  153.      data[13].hours := 7;
  154.      data[14].name := 'NAIROBI';
  155.      data[14].secs := 0;
  156.      data[14].mins := 0;
  157.      data[14].hours := 3;
  158.      data[15].name := 'AUCKLAND';
  159.      data[15].secs := 0;
  160.      data[15].mins := 0;
  161.      data[15].hours := 12;
  162.      data[16].name := 'MEXICO CITY';
  163.      data[16].secs := 0;
  164.      data[16].mins := 0;
  165.      data[16].hours := 6;
  166.      presetclock;
  167.      precalc;
  168.      cleardevice;
  169.      setcolor(lightblue);
  170.      settextstyle(8,0,3);
  171.      outtextxy(200,10,'WORLD TIME CLOCK');
  172.      outtextxy(200,440,'By Nathan Dawson');
  173.      rectangle(1,1,639,479);
  174.      settextstyle(7,0,1);
  175.      setcolor(lightgreen);
  176.      for loop := 1 to 8 do
  177.      begin
  178.           outtextxy(10,10+loop*50,data[loop].name);
  179.      end;
  180.      co := 50;
  181.      for loop2 := 9 to no do
  182.      begin
  183.           outtextxy(300,loop2+co,data[loop2].name);
  184.           co := co + 49;
  185.      end;
  186.      repeat
  187.      for loop := 1 to 8 do
  188.      begin
  189.           clock(200,10+loop*50,lz(data[loop].secs));
  190.           clock(155,10+loop*50,lz(data[loop].mins));
  191.           clock(110,10+loop*50,lz(data[loop].hours));
  192.      end;
  193.      co := 40;
  194.      for loop2 := 9 to no do
  195.      begin
  196.           clock(520,10+loop2+co,lz(data[loop2].secs));
  197.           clock(475,10+loop2+co,lz(data[loop2].mins));
  198.           clock(430,10+loop2+co,lz(data[loop2].hours));
  199.           co := co + 49;
  200.      end;
  201.      showtime;
  202.      until keypressed;
  203.      closegraph;
  204.      gotoxy(17,1);
  205.      textcolor(blue);
  206.      write('Thank you for using the World Time Clock');
  207.      gotoxy(17,3);
  208.      textcolor(cyan);
  209.      write('      Look out for more software by     ');
  210.      gotoxy(17,5);
  211.      textcolor(lightcyan);
  212.      write('       ░▒▓                     ▓▒░      ');
  213.      gotoxy(31,5);
  214.      textcolor(lightred+blink);
  215.      write('NATHAN DAWSON');
  216.      writeln;
  217.      textcolor(lightgray);
  218. end.
  219.  
  220. { CFONT UNIT NEEDED FOR CLOCK.PAS }
  221.  
  222. unit cfont;
  223.  
  224. interface
  225.  
  226. procedure clock(px,y:integer;numbers:string);
  227.  
  228. implementation
  229.  
  230. uses crt,graph;
  231.  
  232. procedure clock;
  233.  
  234. var
  235.    gm,gd  : integer;
  236.    p1     : integer;
  237.    p2     : integer;
  238.    p3     : integer;
  239.    testno : string;
  240.    no1    : string[1];
  241.    count  : integer;
  242.    posx   : integer;
  243.    posy   : integer;
  244.  
  245. function IntToStr(I: Longint): String;
  246.  
  247. var
  248.  S: string[11];
  249.  
  250. begin
  251.  Str(I, S);
  252.  IntToStr := S;
  253. end;
  254.  
  255. procedure resetvars;
  256. begin
  257.      p1 := 0;
  258.      p2 := 0;
  259.      p3 := 0;
  260. end;
  261.  
  262. procedure section1;
  263. begin
  264.      resetvars;
  265.      p3 := 3;
  266.      repeat
  267.            dec(p3);
  268.            dec(p2);
  269.            inc(p1);
  270.            line(posx+p3,posy+p2,posx+p3,posy+5+p1);
  271.      until p3 = 0;
  272. end;
  273.  
  274. procedure section2;
  275. begin
  276.      resetvars;
  277.      repeat
  278.            inc(p3);
  279.            dec(p2);
  280.            inc(p1);
  281.            line(posx+10+p3,posy+p2,posx+10+p3,posy+5+p1);
  282.      until p3 = 3;
  283. end;
  284.  
  285. procedure section3;
  286. begin
  287.      resetvars;
  288.      p3 := 3;
  289.      repeat
  290.            dec(p3);
  291.            dec(p2);
  292.            inc(p1);
  293.            line(posx+p3,posy+14+p2,posx+p3,posy+19+p1);
  294.      until p3 = 0;
  295. end;
  296.  
  297. procedure section4;
  298. begin
  299.      resetvars;
  300.      repeat
  301.            inc(p3);
  302.            dec(p2);
  303.            inc(p1);
  304.            line(posx+10+p3,posy+14+p2,posx+10+p3,posy+19+p1);
  305.      until p3 = 3;
  306. end;
  307.  
  308. procedure section5;
  309.  
  310. begin
  311.      resetvars;
  312.      p3 := 3;
  313.      repeat
  314.            dec(p3);
  315.            dec(p2);
  316.            inc(p1);
  317.            line(posx+5+p2,posy-5+p3,posx+8+p1,posy-5+p3);
  318.      until p3 = 0;
  319. end;
  320.  
  321. procedure section6;
  322.  
  323. begin
  324.      resetvars;
  325.      repeat
  326.            inc(p3);
  327.            dec(p2);
  328.            inc(p1);
  329.            line(posx+5+p2,posy+21+p3,posx+8+p1,posy+21+p3);
  330.      until p3 = 3;
  331. end;
  332.  
  333. procedure section7;
  334.  
  335. begin
  336.      resetvars;
  337.            line(posx+4,posy+9,posx+9,posy+9);
  338.            line(posx+3,posy+10,posx+10,posy+10);
  339.            line(posx+4,posy+11,posx+9,posy+11);
  340. end;
  341.  
  342. procedure on;
  343. begin
  344.      setcolor(lightgreen);
  345. {     setrgbpalette(lightgreen,0,60,0);}
  346. end;
  347.  
  348. procedure off;
  349. begin
  350.      setcolor(green);
  351. {     setrgbpalette(green,0,20,0);       }
  352. end;
  353.  
  354. procedure shownumber(x:string);
  355.  
  356. begin
  357.      if x = '0' then
  358.      begin
  359.           on;
  360.           section1;
  361.           section2;
  362.           section3;
  363.           section4;
  364.           section5;
  365.           section6;
  366.           off;
  367.           section7;
  368.      end;
  369.      if x = '1' then
  370.      begin
  371.           off;
  372.           section1;
  373.           on;
  374.           section2;
  375.           off;
  376.           section3;
  377.           on;
  378.           section4;
  379.           off;
  380.           section5;
  381.           section6;
  382.           section7;
  383.  
  384.      end;
  385.      if x = '2' then
  386.      begin
  387.           off;
  388.           section1;
  389.           on;
  390.           section2;
  391.           section3;
  392.           off;
  393.           section4;
  394.           on;
  395.           section5;
  396.           section6;
  397.           section7;
  398.      end;
  399.      if x = '3' then
  400.      begin
  401.           off;
  402.           section1;
  403.           on;
  404.           section2;
  405.           off;
  406.           section3;
  407.           on;
  408.           section4;
  409.           section5;
  410.           section6;
  411.           section7;
  412.  
  413.      end;
  414.      if x = '4' then
  415.      begin
  416.           on;
  417.           section1;
  418.           section2;
  419.           off;
  420.           section3;
  421.           on;
  422.           section4;
  423.           off;
  424.           section5;
  425.           section6;
  426.           on;
  427.           section7;
  428.      end;
  429.      if x = '5' then
  430.      begin
  431.           on;
  432.           section1;
  433.           off;
  434.           section2;
  435.           section3;
  436.           on;
  437.           section4;
  438.           section5;
  439.           section6;
  440.           section7;
  441.      end;
  442.      if x = '6' then
  443.      begin
  444.           on;
  445.           section1;
  446.           off;
  447.           section2;
  448.           on;
  449.           section3;
  450.           section4;
  451.           section5;
  452.           section6;
  453.           section7;
  454.      end;
  455.      if x = '7' then
  456.      begin
  457.           off;
  458.           section1;
  459.           on;
  460.           section2;
  461.           off;
  462.           section3;
  463.           on;
  464.           section4;
  465.           section5;
  466.           off;
  467.           section6;
  468.           section7;
  469.      end;
  470.      if x = '8' then
  471.      begin
  472.           on;
  473.           section1;
  474.           section2;
  475.           section3;
  476.           section4;
  477.           section5;
  478.           section6;
  479.           section7;
  480.      end;
  481.      if x = '9' then
  482.      begin
  483.           on;
  484.           section1;
  485.           section2;
  486.           off;
  487.           section3;
  488.           on;
  489.           section4;
  490.           section5;
  491.           section6;
  492.           section7;
  493.      end;
  494. end;
  495.  
  496. procedure setup;
  497.  
  498. var
  499.    loop : integer;
  500.  
  501. begin
  502.      for loop := 1 to 2 do
  503.      begin
  504.           posx := px+loop*20;
  505.           posy := y;
  506.           no1 := copy(numbers,loop,loop);
  507.           shownumber(no1);
  508.      end;
  509. end;
  510.  
  511. begin
  512.      setcolor(lightgreen);
  513.      setrgbpalette(lightgreen,0,60,0);
  514.      setcolor(green);
  515.      setrgbpalette(green,0,20,0);
  516.      setup;
  517. end;
  518. end.